<template>
    <div class="equipment-things-more-info">
        <el-form label-width="150px" class="demo-table-expand">
            <el-form-item label="所属通信服务器：">
                <span>{{ formInfo.serverName }}</span>
            </el-form-item>
            <el-form-item label="上级：">
                <span>{{ formInfo.parentName }}</span>
            </el-form-item>
            <el-form-item label="复位方式：">
                <span>{{ mapResetMode(formInfo.resetMode) }}</span>
            </el-form-item>
            <el-form-item label="关联其他物联设备：">
                <span>{{ formInfo.relateFcfNames }}</span>
            </el-form-item>
            <el-form-item label="生产厂家：">
                <span>{{ formInfo.producerName }}</span>
            </el-form-item>
            <el-form-item label="入库时间：">
                <span>{{ formInfo.createTimeStr }}</span>
            </el-form-item>
            <el-form-item label="关联资产：">
                <template v-if="formInfo.assetList.length > 0">
                    <span v-for="(item, index) in formInfo.assetList" :key="item.id">
                        <el-link type="primary" @click="jumpOtherPage(item)">{{ item.name }}</el-link>
                        <span v-if="index != (formInfo.assetList.length -1)">、</span>
                    </span>
                </template>
                <template v-else>
                    <span>无</span>
                </template>
            </el-form-item>
        </el-form>
    </div>
</template>
<script>
import { getAlarmFcfMoreInfo } from '@/api/alarm'

export default {
    name: '',
    props: {
        info: {
            required: true
        }
    },
    data() {
        return {
            formInfo: {
                serverName: '',
                parentName: '',
                relateFcfNames: '',
                resetMode: this.info.resetMode,
                producerName: this.info.producerName,
                createTimeStr: this.info.createTimeStr,
                assetList: []
            }
        }
    },
    created() {
        let that = this
        getAlarmFcfMoreInfo({
            fcfId: that.info.id
        }).then(res => {
            that.formInfo.serverName = res.data.serverName || '无'
            that.formInfo.parentName = res.data.parentName || '无'
            that.formInfo.relateFcfNames = res.data.relateFcfNames || '无'
            that.formInfo.assetList = res.data.assetList
            that.formInfo.resetMode = res.data.resetMode
        })
    },
    methods: {
        jumpOtherPage(obj) {
            let params = {
                level: 2, // level  页面跳转显示   1-多单位   2-单单位
                orgId: obj.organizationId, // 单位编码
                orgName: this.info.organizationName, // 单位名称
                name: obj.name // 搜索内容
            }
            this.$router.push({
                name:'assetList',
                params
            })
        },
        mapResetMode(code) {
            let mapList = {
                '0': '自复位',
                '1': '处理后复位'
            }
            return mapList[code] || '-'
        }
    }
}
</script>
<style lang="scss">
.equipment-things-more-info {
    .el-form-item {
        margin-bottom: 0;
    }
}
</style>